package com.huike.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huike.entity.Admin;
import com.huike.utils.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.huike.service.IAdminService;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/MembersController")
@Controller
public class MembersController{
	
	@Autowired
	IAdminService adminService;

	@RequestMapping("/getMembersList")
	@ResponseBody
	public void getMembersList(HttpServletResponse response,int page ,String keyWord) {
		IPage<Admin> res = adminService.getMembersList(page,keyWord);
		Map<String,Object> map = new HashMap<>();
		map.put("code",0);
		map.put("total",res.getTotal());
		map.put("data",res.getRecords());
		map.put("pages",res.getPages());
		JsonUtils.jsonArray(map,response);
	}


	@RequestMapping("/getMemberCerticicate")
	@ResponseBody
	public void getMemberCerticicate(HttpServletResponse response, String uid) {
		String certificate=adminService.getMemberCerticicate(uid);
		Map map=new HashMap();
		map.put("certificate", certificate);
		JSONObject obj = new JSONObject(map);
		JsonUtils.jsonArray(map,response);
	}
}
